package user

import (
	status "AI/util"
	"fmt"
	"net/http"

	"github.com/gin-gonic/gin"
)

type ImageType struct {
	Account  string
	ImageUrl string
}

func SetImage(c *gin.Context) {
	fmt.Println("测试")
	var ImageUrl string = GetImageUrl(c)
	fmt.Println(ImageUrl)
	if ImageUrl == "false" {
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code": status.Success,
		"body": "图片上传成功",
	})
}
func GetImageUrl(c *gin.Context) string {
	url, _ := c.Get("ImageUrl")
	fmt.Println(url == nil)
	if len([]rune(fmt.Sprintf("%v", url))) <= 0 || url == nil {
		c.JSON(http.StatusOK, gin.H{
			"code": status.Fieldsmissing,
			"body": "保存头像失败",
		})
		return "false"
	}
	// 123
	return fmt.Sprintf("%v", url)
}
